package com.handpay.zztong.hp.accountcenter.model.modifycard;
import com.handpay.framework.fastjson.FastJsonHelper;
import com.handpay.zztong.hp.R;
import com.handpay.zztong.hp.base.activity.ZZTongActivity;
import com.handpay.zztong.hp.base.callback.BusinessEngineListener;
import com.handpay.zztong.hp.base.model.base.BaseModel;
import com.handpay.zztong.hp.bean.ResponseBean;
import com.handpay.zztong.hp.config.HttpUrlConstant;

import java.util.Hashtable;

/**
 * Created by lyang on 2017/3/23.
 */

public class ModifyCardModel extends BaseModel {
    private BusinessEngineListener mBusinessEngineListener;
    private ZZTongActivity mActivity;

    /**
     * 修改收款账户信息
     * @param activity
     * @param params
     * @param listener
     * @return
     */
    public boolean doModifyCardPost(ZZTongActivity activity, Hashtable<String, String> params, BusinessEngineListener listener) {
        mBusinessEngineListener = listener;
        mActivity = activity;
        return doPost(activity, HttpUrlConstant.DO_zztModifyCardNum, params, true, true);
    }

    @Override
    public boolean netResponse(String action, byte[] data) {
        boolean bResult = super.netResponse(action, data);
        if (bResult) {
            return true;
        }
        if (action.equals(HttpUrlConstant.DO_zztModifyCardNum)) {
            ResponseBean bean = null;
            if (data_type == DATA_TYPE.DATA_TYPE_JSON) {
                try {
                    String result = new String(data, "UTF-8");
                    bean = FastJsonHelper.getObject(result, ResponseBean.class);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {

            }
            if (mBusinessEngineListener != null) {
                mBusinessEngineListener.callbackBusinessResponse(bean);
            }
        }
        return true;
    }
}